package com.hejjon.controller;

import com.hejjon.core.bean.ResponseResult;
import com.hejjon.core.bean.StrListBean;
import com.hejjon.core.controller.BaseController;
import com.hejjon.core.enumer.DeleteFlagEnum;
import com.hejjon.domain.request.FeatureFieldBatchSaveRequest;
import com.hejjon.domain.response.FeatureFieldBatchSaveResponse;
import com.hejjon.domain.vo.FeatureFieldVO;
import com.hejjon.service.IFeatureFieldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author: cs
 * @date: 2025-05-15 14:07:48
 * @since: 1.0
 */
@RestController
@RequestMapping("/feature/field")
public class FeatureFieldController extends BaseController {


    @Autowired
    private IFeatureFieldService featureFieldService;


//    @PostMapping("/create")
//    public ResponseResult create(@Valid @RequestBody FeatureFieldCreateRequest request) {
//        FeatureFieldCreateResponse response = featureFieldService.create(request);
//        return toResult(response.getStatus(), response.getMessage());
//    }

    @PostMapping("/batchSave")
    public ResponseResult batchSave(@Valid @RequestBody FeatureFieldBatchSaveRequest request) {
        FeatureFieldBatchSaveResponse response = featureFieldService.batchSave(request);
        return toResult(response);
    }

    @GetMapping("/listByFeatureId")
    public ResponseResult listByFeatureId(@RequestParam String featureId) {
        List<FeatureFieldVO> fieldVOList = featureFieldService.findByFeatureId(featureId);
        return success(fieldVOList);
    }


    @PostMapping("/removeByFieldIds")
    public ResponseResult removeByFieldIds(@RequestBody StrListBean  bean) {
        return toResult(featureFieldService.batchRemoveByFieldId(bean.getIds(), DeleteFlagEnum.YES.getCode()));
    }


}
